package com.goodfox.web.generic.provide.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * 生成唯一一串字符串
 * @author qin gt
 *
 */
public class UUIDUtil {
	
	/** 循环起始数 */
	private static final int START_NUM = 100;
	
	/** 循环结束数 */
	private static final int END_NUM = 999;
	
	/** 循环变量 */
	private static int LOOP_NUM = START_NUM;

	/**
	 * 获取唯一字串
	 * @return
	 */
	public static String getGUID() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		StringBuffer buffer = new StringBuffer(sdf.format(new Date()));
		if (LOOP_NUM == END_NUM){
			LOOP_NUM = START_NUM;
		}
		buffer.append(new Integer(LOOP_NUM++).toString());
		return buffer.toString();
	}
	
	public static String getCUID(){
		return getUUID()+getGUID();
	}
	
	public static String getUUID(){
		return UUID.randomUUID().toString().replace("-", "");
	}
}
